# import pymouse,pykeyboard,os,sys
# from pykeyboard import PyKeyboard

from pynput.keyboard import Key, Controller
from pynput import keyboard
keyboard_output = Controller()
def on_press(key):
 try:
#   print('alphanumeric key {0} pressed'.format(key.char))
    pass
 except AttributeError:
  print('special key {0} pressed'.format(key))

def on_release(key):
#  print('{0} released'.format(key))
      if key == keyboard.Key.esc:
            return False
      elif key == keyboard.Key.left:
            keyboard_output.press(Key.ctrl)
            keyboard_output.press(Key.alt)
            keyboard_output.press(',')
            keyboard_output.release(',')
            keyboard_output.release(Key.alt)
            keyboard_output.release(Key.ctrl)
      elif key == keyboard.Key.right:
            keyboard_output.press(Key.ctrl)
            keyboard_output.press(Key.alt)
            keyboard_output.press('.')
            keyboard_output.release('.')
            keyboard_output.release(Key.alt)
            keyboard_output.release(Key.ctrl)      

while True:
 with keyboard.Listener(
  on_press = on_press,
  on_release = on_release) as listener:
  listener.join()